package top.suven.base.http.admin;

import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import top.suven.base.http.admin.frame.config.WebConfigurationAdapter;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;

@Import({
//		EmbeddedServletContainerAutoConfiguration.class,
		DispatcherServletAutoConfiguration.class,
		HttpMessageConvertersAutoConfiguration.class,
		WebConfigurationAdapter.class,
})
@ServletComponentScan
@ComponentScan("top.suven.base")
@EnableAutoConfiguration
public class AdminMain  extends SpringBootServletInitializer {

	public static void main(String[] args) {
		SpringApplication.run(AdminMain.class, args);
	}


	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
		return builder.sources(AdminMain.class).bannerMode(Banner.Mode.OFF);
	}
	//DataSource配置
//	@Bean
//	@ConfigurationProperties(prefix="gc.datasource.admin.master")
//	public DataSource dataSource() {
//		DruidDataSource druidDataSource = new DruidDataSource();
//		return druidDataSource;
//	}

	//	提供SqlSeesion
//	@Bean("sqlSeesion")
//	public SqlSessionFactory sqlSessionFactoryBean() throws Exception {
//
//		SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
//		sqlSessionFactoryBean.setDataSource(dataSource());
//
//		PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
//
//		//sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:/mybatis/*.xml"));//映射文件是resource/mybatis/目录下所有.xml文件
//
//		return sqlSessionFactoryBean.getObject();
//	}
//
//	@Bean(name = "txManager")
//	public PlatformTransactionManager txManager() {
//		return new DataSourceTransactionManager(dataSource());
//	}
}
